//
//  ShopCell.m
//  MyTest
//
//  Created by zhiyou on 16-4-18.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "ShopCell.h"

@implementation ShopCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _headView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_headView];
        
        _contentLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _contentLab.font = [UIFont systemFontOfSize:11];
        _contentLab.numberOfLines = 0;
        [self.contentView addSubview:_contentLab];
        
        _storeLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _storeLab.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_storeLab];
        
        _priceLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _priceLab.font = [UIFont systemFontOfSize:11];
        _priceLab.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLab];
        
        _timeLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _timeLab.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_timeLab];
        
        
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.offset(5);
            make.bottom.offset(-5);
            make.width.equalTo(_headView.mas_height);
        }];

        [_contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.top.offset(10);
            make.right.offset(-5);
        }];
        
        [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.top.equalTo(_contentLab.mas_bottom).offset(20);
        }];
        
        [_storeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(5);
            make.bottom.offset(-10);
        }];
        
        [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-5);
            make.bottom.offset(-10);
        }];
    }
    return self;
}
- (void)setGoods:(Goods *)goods
{
    _goods = goods;
    
    [_headView sd_setImageWithURL:[NSURL URLWithString:_goods.img]];
    _contentLab.text = _goods.title;
    _storeLab.text = _goods.orginal_type;
    _priceLab.text = _goods.subtitle;
    _timeLab.text = _goods.date;
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
